.TH std::subtract_with_carry_engine 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::subtract_with_carry_engine \- std::subtract_with_carry_engine

.SH Synopsis
   Defined in header <random>
   template<

       class UIntType,                              \fI(since C++11)\fP
       std::size_t w, std::size_t s, std::size_t r

   > class subtract_with_carry_engine;

   Is a random number engine that uses subtract with carry algorithm.

.SH Template parameters

              The result type generated by the generator. The effect is undefined if
   UIntType - this is not one of unsigned short, unsigned int, unsigned long, or
              unsigned long long.
   w        - the word size, in bits, of the state sequence
   s        - the short lag
   r        - the long lag

   If w is not in [1, std::numeric_limits<UIntType>::digits], or s is not in [1, r),
   the program is ill-formed.

   Generator properties

   The size of the states of subtract_with_carry_engine is \\(O(r)\\)O(r), each of them
   consists of two parts:

     * A sequence X of r integer values, where each value is in [0, 2w
       ).
     * An integer c (known as the carry ), whose value is either 0 or 1.

   Given that \\(X_j\\)X
   j stands for the \\(j\\mod r\\)j mod rth value (starting from 0) of X, the transition
   algorithm of subtract_with_carry_engine (\\(TA(x_i)\\)TA(x
   i)) is defined as follows:

    1. Let Y be \\(X_{i-s}-X_{i-r}-c\\)X
       i-s-X
       i-r-c.
    2. Let y be \\(Y\\mod 2^w\\)Y mod 2w
       , and set \\(X_i\\)X
       i to y.
    3. If Y is negative, set c to 1, otherwise set c to 0.

   The generation algorithm of subtract_with_carry_engine is \\(GA(x_i) = y\\)GA(x
   i) = y, where y is the value produced in step 2 of the transition algorithm.

   Predefined specializations

   The following specializations define the random number engine with two commonly used
   parameter sets:

   Defined in header <random>
   Type                 Definition
   ranlux24_base        std::subtract_with_carry_engine<std::uint_fast32_t, 24, 10,
   \fI(C++11)\fP              24>
   ranlux48_base        std::subtract_with_carry_engine<std::uint_fast64_t, 48, 5,
   \fI(C++11)\fP              12>

   Nested types

   Type        Definition
   result_type UIntType

   Data members

   constexpr std::size_t word_size            w
   \fB[static]\fP                                   \fI(public static member constant)\fP
   constexpr std::size_t short_lag            s
   \fB[static]\fP                                   \fI(public static member constant)\fP
   constexpr std::size_t long_lag             r
   \fB[static]\fP                                   \fI(public static member constant)\fP
   constexpr std::uint_least32_t default_seed 19780503u
   \fB[static]\fP                                   \fI(public static member constant)\fP

.SH Member functions

.SH Construction and Seeding
   constructor      constructs the engine
   \fI(C++11)\fP          \fI(public member function)\fP
   seed             sets the current state of the engine
   \fI(C++11)\fP          \fI(public member function)\fP
.SH Generation
   operator()       advances the engine's state and returns the generated value
   \fI(C++11)\fP          \fI(public member function)\fP
   discard          advances the engine's state by a specified amount
   \fI(C++11)\fP          \fI(public member function)\fP
.SH Characteristics
   min              gets the smallest possible value in the output range
   \fB[static]\fP \fI(C++11)\fP \fI(public static member function)\fP
   max              gets the largest possible value in the output range
   \fB[static]\fP \fI(C++11)\fP \fI(public static member function)\fP

.SH Non-member functions

   operator==                compares the internal states of two pseudo-random number
   operator!=                engines
   \fI(C++11)\fP                   \fI(function)\fP
   \fI(C++11)\fP(removed in C++20)
   operator<<                performs stream input and output on pseudo-random number
   operator>>                engine
   \fI(C++11)\fP                   \fI(function template)\fP

.SH Example

    This section is incomplete
    Reason: no example

   Defect reports

   The following behavior-changing defect reports were applied retroactively to
   previously published C++ standards.

      DR    Applied to     Behavior as published       Correct behavior
   LWG 3809 C++11      default_seed might not be      changed its type to
                       representable with result_type std::uint_least32_t

.SH Category:
     * Todo no example
